package com.zkdcloud.repository;

import com.zkdcloud.domain.Cart;
import org.jfaster.mango.annotation.DB;
import org.jfaster.mango.annotation.SQL;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zk123
 * @version 2018/5/23
 */
@DB(table = "cart")
@Repository
public interface CartDao {
    String COLUMNS = " id,business_id,last_address_id,pay_method,origin_price,discount_price,total_price,create_time ";

    /**
     * 添加cart
     *
      * @param cart cart
     */
    @SQL("insert into #table("+COLUMNS+")values(:id,:businessId,:lastAddressId,:payMethod,:originPrice," +
            ":discountPrice,:totalPrice,:createTime)")
    void add(Cart cart);

    /**
     * 获取所有cart列表
     *
     * @return cart
     */
    @SQL("select * from #table")
    List<Cart> getAll();

    /**
     * 获取One
     *
     * @param id id
     * @return getOne
     */
    @SQL("select * from #table where id = :1")
    Cart getOne(String id);
}
